#coding=utf-8

#获得比指定数大，但是最小的数

import unittest
import sys
  
###########取最小数字#####


#get the digit list for one integer
#input: 19, output: [1,9]   input: 100, output:[1,0]
def get_digits(number):   
    a = []
    new = number
    while True:
        digit = new % 10
        if digit not in a:
            a.append(digit)
        new = new /10
        if new == 0:
            return a

#find the integer
def find(lists, number):
  try:    
    if number < 0:
        number = 0
    bvalid = True
    for dd in lists:
        if type(dd)is int:
            if dd < 0 or dd > 9:
                bvalid = False
                break
        else:
            bvalid = False
    if not bvalid:
        print "parameters invalid"
        return
      
    b = False
    for i in xrange(number+1, number*10+10):
        for d in get_digits(i):
            if d not in lists:
                b = False
                break
            else:
                b = True
        if b:
            return i
  except:    
    print sys.exc_info()
    print "Pleas contact sanjiely@gmail.com"
    

td = [[[1,2], 99],
       [[0,2],33],
       [[0,2],333],
       [[0,2],1],
       [[0,2],0],
       [[0,2],999],
       [[0,2],-1],
       ]    
class MyTest(unittest.TestCase):

    def runTest(self):
        for l in td:
            print l[0], "for ", l[1], " = ", find(l[0], l[1])
        
    
    
if __name__ == '__main__':   
       
    #test()
    #print get_digits(100)
    #print find([9, 0, 1], 99999999)
    unittest.main();
    